<?php
 /*
 * 1626cms 管理中心 友情鏈接 數據調用函數
 * ============================================================================
 * 版權所有: 1626網絡，并保留所有權利。
 * 網站地址: http://www.1626.com；
 * ----------------------------------------------------------------------------
 * 這不是一個自由軟件！您只能在不用于商業目的的前提下對程序代碼進行修改和
 * 使用；不允許對程序代碼以任何形式任何目的的再發布。
 * ============================================================================
*/
 if(!defined('IN_QISHI'))
 {
 	die('Access Denied!');
 }
 //獲取友情鏈接分類
function get_link_category(){
global $db;
$sql = "select * from ".table('link_category')."  ORDER BY category_order desc,id asc";
$category_list=$db->getall($sql);
return $category_list;
}
 //根據友情鏈接分類ID獲取分類名稱
function get_link_category_name($val)
{
global $db;
$sql = "select * from ".table('link_category')." where id=".$val;
$category=$db->getone($sql);
$categoryname=$category['categoryname'];
return $categoryname;
}
//讀取友情鏈接
function get_links($offset, $perpage, $get_link_sql= ''){
 	global $db;
	global $upfiles_dir;
 	$row_arr = array();
 	if(isset($offset)&&!empty($perpage)){
 		$result = $db->query("SELECT * FROM ".table('link').$get_link_sql." ORDER BY show_order DESC,link_id DESC LIMIT ".$offset.','.$perpage);
 		while($row = $db->fetch_array($result)){
		$row['link_logo']=($row['link_logo'] and strpos($row['link_logo'],"http://")===0)?$row['link_logo']:($row['link_logo']?$upfiles_dir.$row['link_logo']:'');
		$row['category_name'] = get_link_category_name($row['category_id']);
 		$row_arr[] = $row;
 		}
 	}else{
 		$result = $db->query("SELECT * FROM ".table('link').$get_link_sql." ORDER BY show_order DESC,link_id DESC" );
 		while($row = $db->fetch_array($result)){
		$row['category_name'] = get_link_category_name($row['category_id']);
 		$row_arr[] = $row;
 		}
 	}
 	return $row_arr;
 }
?>
